Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
Can I define "document" as a variable in Javascript?

In my application, I sometimes want to define "document" for use in querySelector as "tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document". Other times, I want "document" to have it's usual meaning.

Is there a way I can set "document" to be a variable? I've tried the following, none of which return an element:

Defining document:

document = tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document;
document.querySelector(myElement)  // Returns nothing

Defining a prefix:

prefix = tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow;
prefix.document.querySelector(myElement);  //Returns nothing

Defining a prefix as text:

prefix = "tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow;
    prefix.document.querySelector(myElement)";  //Returns nothing

Only tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document.querySelector(myElement) returns an element.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I found my own answer. I'll post it in case anyone else comes across this post.

First, find your TinyMCE Editor iframe

var iframe = document.querySelector("#myDiv .tox-editor-container .tox-edit-area iframe");

Then get its contents

var iframe_content = iframe.contentDocument;

Then you can perform your queries

var frame_li = iframe_content.querySelectorAll("#tinymce li");
about 4 years ago · Juan Pablo Isaza Relatório

0

Have you tried window.orig_document = window.document window.document = tinymce.get('steps_html').contentAreaContainer.childNodes[0].contentWindow.document window.document = window.document.orig_document

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda